package com.adee.nowcoder.huawei;

import java.util.Scanner;

public class T018_HJ18 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int A = 0;
        int B = 0;
        int C = 0;
        int D = 0;
        int E = 0;
        int ERR = 0;
        int PRIVATE = 0;
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            if(str.trim().length() == 0) break;
            String[] arr = str.split("~");
            String ip = arr[0].trim();
            String mask = arr[1].trim();

            int ipInt = ipToInt(ip);
            if (ipInt == -1) {
                ++ERR;
            } else {
                int a = ipToInt("10.0.0.0");
                int b = ipToInt("10.255.255.255");
                int c = ipToInt("128.0.0.0");
                int d = ipToInt("191.255.255.255");

                if (compare(ipInt, ipToInt("1.0.0.0"))>0
                        && compare(ipInt, ipToInt("126.255.255.255"))<0) {
                    ++A;
                } else if(compare(ipInt, ipToInt("128.0.0.0"))>0
                        && compare(ipInt, ipToInt("191.255.255.255"))<0) {
                    ++B;
                } else if(compare(ipInt, ipToInt("192.0.0.0"))>0
                        && compare(ipInt, ipToInt("223.255.255.255"))<0) {
                    ++C;
                } else if(compare(ipInt, ipToInt("224.0.0.0"))>0
                        && compare(ipInt, ipToInt("239.255.255.255"))<0) {
                    ++D;
                } else if(compare(ipInt, ipToInt("240.0.0.0"))>0
                        && compare(ipInt, ipToInt("255.255.255.255"))<0) {
                    ++E;
                }
                if(
                        (compare(ipInt, ipToInt("10.0.0.0"))>0 && compare(ipInt, ipToInt("10.255.255.255"))<0)
                                || (compare(ipInt, ipToInt("172.16.0.0"))>0 && compare(ipInt, ipToInt("172.31.255.255"))<0)
                                || (compare(ipInt, ipToInt("192.168.0.0"))>0 && compare(ipInt, ipToInt("192.168.255.255"))<0)
                ) {
                    ++PRIVATE;
                }
            }
            if (!maskLegal(mask)) {
                ++ERR;
            }

        }
        System.out.printf("%d %d %d %d %d %d %d", A, B, C, D, E, ERR, PRIVATE);
    }

    static int ipToInt(String ip) {
        String[] arr = ip.split("\\.");
        if (arr.length == 4) {
            if (arr[0].length() > 0 && arr[1].length() > 0
                    && arr[2].length() > 0 && arr[3].length() > 0) {
                int p0 = Integer.parseInt(arr[0]) & 0xFF;
                int p1 = Integer.parseInt(arr[1]) & 0xFF;
                int p2 = Integer.parseInt(arr[2]) & 0xFF;
                int p3 = Integer.parseInt(arr[3]) & 0xFF;
                int ipInt = (p0 << 24) + (p1 << 16) + (p2 << 8) + p3;
                return ipInt;
            }
        }
        return -1;
    }

    static boolean maskLegal(String mask) {
        String[] arr = mask.split("\\.");
        if (arr.length == 4) {
            if (arr[0].length() > 0 && arr[1].length() > 0
                    && arr[2].length() > 0 && arr[3].length() > 0) {
                int p0 = Integer.parseInt(arr[0]) & 0xFF;
                int p1 = Integer.parseInt(arr[1]) & 0xFF;
                int p2 = Integer.parseInt(arr[2]) & 0xFF;
                int p3 = Integer.parseInt(arr[3]) & 0xFF;
                int maskInt = (p0 << 24) + (p1 << 16) + (p2 << 8) + p3;
                while (maskInt < 0) {
                    maskInt = maskInt << 1;
                }
                return maskInt == 0;
            }
        }
        return false;
    }

    // a和b按无符号类型比较
    static int compare(int a, int b) {
        char[] baseA = "00000000000000000000000000000000".toCharArray();
        char[] arrA = Integer.toBinaryString(a).toCharArray();
        System.arraycopy(arrA, 0, baseA, 32-arrA.length, arrA.length);
        char[] baseB = "00000000000000000000000000000000".toCharArray();
        char[] arrB = Integer.toBinaryString(b).toCharArray();
        System.arraycopy(arrB, 0, baseB, 32-arrB.length, arrB.length);
        for (int i = 0; i < 32; i++) {
            if(baseA[i] > baseB[i]) return 1;
            else if(baseA[i] < baseB[i]) return -1;
        }
        return 0;
    }
}
